import time
from multiprocessing import Queue, Process


def download(q):
    print('开始下载...')
    files = ['book.txt', 'table.jpg', 'girl.png']
    for file in files:
        print('正在下载:', file)
        q.put(file)
        time.sleep(1)


def store_file(q):
    while not q.empty():
        file = q.get()
        print('{}保存成功'.format(file))


if __name__ == '__main__':
    q = Queue(5)
    d = Process(target=download, args=(q,))
    s = Process(target=store_file, args=(q,))

    d.start()
    d.join()

    s.start()
    s.join(timeout=5)